package com.kxc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kxc.dao.SurfaceDisplacementWarnDao;
import com.kxc.entity.SurfaceDisplacementWarn;
/**
 * 表面位移测点预警信息设置业务类
 */
@Service
public class SurfaceDisplacementWarnService {

	@Autowired
	private SurfaceDisplacementWarnDao surfaceDisplacementWarnDao;

	public SurfaceDisplacementWarn add(SurfaceDisplacementWarn surfaceDisplacementWarn) {
		return surfaceDisplacementWarnDao.save(surfaceDisplacementWarn);
	}

	public int update(SurfaceDisplacementWarn surfaceDisplacementWarn) {
		SurfaceDisplacementWarn surfaceDisplacementWarn2 = surfaceDisplacementWarnDao.findByPointNum(surfaceDisplacementWarn.getPointNum());
		if(surfaceDisplacementWarn2!=null){
			return surfaceDisplacementWarnDao.updateSurfaceDisplacementWarn(surfaceDisplacementWarn.getPointNum(), surfaceDisplacementWarn.getsBW(), 
					surfaceDisplacementWarn.getlBW(), surfaceDisplacementWarn.getsYW(), surfaceDisplacementWarn.getlYW(), surfaceDisplacementWarn.getsOW(),
					surfaceDisplacementWarn.getlOW(),surfaceDisplacementWarn.getsRW(), surfaceDisplacementWarn.getlRW(),surfaceDisplacementWarn.getModifyTime());
		}else{
			return surfaceDisplacementWarnDao.save(surfaceDisplacementWarn)!=null?1:0;
		}
	}

	public SurfaceDisplacementWarn getByPointNum(String pointNum) {
		return surfaceDisplacementWarnDao.findByPointNum(pointNum);
	}
 
}
